import {view} from "cc";

/**
 * 设备工具
 * @author GR
 * @date 2023-12-23 19:04
 */
export class DeviceUtil {

    /**
     * 默认窗口比例
     */
    static DEFAULT_WINDOW_SIZE = {
        width: 640,
        height: 960
    };

    /**
     * 获取屏幕大小
     */
    public static getVisibleSize() {
        return view.getVisibleSize();
    }

    /**
     * 获取屏幕宽度
     */
    public static getViewWidth() {
        return this.getVisibleSize().width;
    }

    /**
     * 获取屏幕高度
     */
    public static getViewHeight() {
        return this.getVisibleSize().height;
    }

    /**
     * 获取宽度比
     */
    public static getWidthScale() {
        return this.getVisibleSize().width / this.DEFAULT_WINDOW_SIZE.width;
    }

    /**
     * 获取高度比
     */
    public static getHeightScale() {
        return this.getVisibleSize().height / this.DEFAULT_WINDOW_SIZE.height;
    }
}